[Java] Type safety: Unchecked cast from Object

Posted by Matthew on Stack Overflow See other posts from Stack Overflow or by Matthew
Published on 2010-04-07T13:10:39Z Indexed on 2010/04/07 13:13 UTC
Read the original article Hit count: 613

Filed under:
|
|
|
|

Hi,

I try to cast an object to my Action class, but it results in a warning:

Type safety: Unchecked cast from Object to Action<ClientInterface>

Action<ClientInterface> action = null;
try {
 Object o = c.newInstance();
 if (o instanceof Action<?>) {
  action = (Action<ClientInterface>) o;
 } else {
  // TODO 2 Auto-generated catch block
  throw new InstantiationException();
 }
 [...]

Thank you for any help

© Stack Overflow or respective owner

Related posts about java

Related posts about type